package android.support.v4.app;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import android.text.TextUtils;
import android.util.Log;
import java.util.ArrayList;

final class BackStackState
  implements Parcelable
{
  public static final Parcelable.Creator CREATOR = new c();
  final int[] a;
  final int b;
  final int c;
  final String d;
  final int e;
  final int f;
  final CharSequence g;
  final int h;
  final CharSequence i;

  public BackStackState(Parcel paramParcel)
  {
    this.a = paramParcel.createIntArray();
    this.b = paramParcel.readInt();
    this.c = paramParcel.readInt();
    this.d = paramParcel.readString();
    this.e = paramParcel.readInt();
    this.f = paramParcel.readInt();
    this.g = ((CharSequence)TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(paramParcel));
    this.h = paramParcel.readInt();
    this.i = ((CharSequence)TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(paramParcel));
  }

  public BackStackState(a parama)
  {
    b localb = parama.b;
    for (int j = 0; localb != null; j = k)
    {
      k = j;
      if (localb.i != null)
        k = j + localb.i.size();
      localb = localb.a;
    }
    this.a = new int[j + parama.d * 7];
    if (!(parama.k))
      throw new IllegalStateException("Not on back stack");
    localb = parama.b;
    j = 0;
    if (localb != null)
    {
      int[] arrayOfInt = this.a;
      k = j + 1;
      arrayOfInt[j] = localb.c;
      arrayOfInt = this.a;
      int l = k + 1;
      if (localb.d != null);
      for (j = localb.d.f; ; j = -1)
      {
        arrayOfInt[k] = j;
        arrayOfInt = this.a;
        j = l + 1;
        arrayOfInt[l] = localb.e;
        arrayOfInt = this.a;
        k = j + 1;
        arrayOfInt[j] = localb.f;
        arrayOfInt = this.a;
        j = k + 1;
        arrayOfInt[k] = localb.g;
        arrayOfInt = this.a;
        k = j + 1;
        arrayOfInt[j] = localb.h;
        if (localb.i == null)
          break;
        l = localb.i.size();
        arrayOfInt = this.a;
        j = k + 1;
        arrayOfInt[k] = l;
        k = 0;
        while (true)
        {
          if (k >= l)
            break label304;
          this.a[j] = ((Fragment)localb.i.get(k)).f;
          k += 1;
          j += 1;
        }
      }
      while (true)
      {
        while (true)
          label304: localb = localb.a;
        arrayOfInt = this.a;
        j = k + 1;
        arrayOfInt[k] = 0;
      }
    }
    this.b = parama.i;
    this.c = parama.j;
    this.d = parama.m;
    this.e = parama.o;
    this.f = parama.p;
    this.g = parama.q;
    this.h = parama.r;
    this.i = parama.s;
  }

  public final a a(m paramm)
  {
    a locala = new a(paramm);
    int l = 0;
    int j = 0;
    while (j < this.a.length)
    {
      b localb = new b();
      Object localObject = this.a;
      int k = j + 1;
      localb.c = localObject[j];
      if (m.a)
        Log.v("FragmentManager", "Instantiate " + locala + " op #" + l + " base fragment #" + this.a[k]);
      localObject = this.a;
      j = k + 1;
      k = localObject[k];
      if (k >= 0);
      for (localb.d = ((Fragment)paramm.f.get(k)); ; localb.d = null)
      {
        localObject = this.a;
        k = j + 1;
        localb.e = localObject[j];
        localObject = this.a;
        j = k + 1;
        localb.f = localObject[k];
        localObject = this.a;
        k = j + 1;
        localb.g = localObject[j];
        localObject = this.a;
        j = k + 1;
        localb.h = localObject[k];
        localObject = this.a;
        k = j + 1;
        int i2 = localObject[j];
        j = k;
        if (i2 <= 0)
          break;
        localb.i = new ArrayList(i2);
        int i1 = 0;
        while (true)
        {
          j = k;
          if (i1 >= i2)
            break label359;
          if (m.a)
            Log.v("FragmentManager", "Instantiate " + locala + " set remove fragment #" + this.a[k]);
          localObject = (Fragment)paramm.f.get(this.a[k]);
          localb.i.add(localObject);
          i1 += 1;
          k += 1;
        }
      }
      label359: locala.a(localb);
      l += 1;
    }
    locala.i = this.b;
    locala.j = this.c;
    locala.m = this.d;
    locala.o = this.e;
    locala.k = true;
    locala.p = this.f;
    locala.q = this.g;
    locala.r = this.h;
    locala.s = this.i;
    locala.a(1);
    return ((a)locala);
  }

  public final int describeContents()
  {
    return 0;
  }

  public final void writeToParcel(Parcel paramParcel, int paramInt)
  {
    paramParcel.writeIntArray(this.a);
    paramParcel.writeInt(this.b);
    paramParcel.writeInt(this.c);
    paramParcel.writeString(this.d);
    paramParcel.writeInt(this.e);
    paramParcel.writeInt(this.f);
    TextUtils.writeToParcel(this.g, paramParcel, 0);
    paramParcel.writeInt(this.h);
    TextUtils.writeToParcel(this.i, paramParcel, 0);
  }
}